package com.ideaction.datacertify;


import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSONObject;
import com.ideaction.globalconst.Result;

/**
 * 数据验证管理器
 *
 * @author ZGame
 */
public class PlayerDataCertifyManager {
    
    private static List<DataCertifier> dataCertifyList = new ArrayList<>();
    
    //验证注册
    static {
        //字段数量验证
        dataCertifyList.add(new PlayerClientDataCountCertifier());
        //金币增量验证
        dataCertifyList.add(new CoinCertifier());
        //签到验证
        dataCertifyList.add(new SignCertifier());
    }
    
    //参数传递进来，参数可以自己去修改
    public static Result certifyPlayerClientData(JSONObject upData, JSONObject oldData, long passTime, String ip,
            long createTime) {
        Result result = Result.build();
        for (DataCertifier dataCertifier : dataCertifyList) {
            result = dataCertifier.dataCertify(upData, oldData, passTime, createTime, ip);
            if (dataCertifier.canCertify() && !result.isOk()) {
                return result;
            }
        }
        return result;
    }
}
